home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_aet_aiframepatrol.cog < prev    next >
Text File  |  1999-11-15  |  3KB  |  139 lines

  1. # Jones 3D Cog Script
  2. #
  3. # aet_AiFramePatrol.cog
  4. #
  5. # "patroller" travels patrol route of frames.
  6. # Patrol begins at startup unless either gosector or gosurface are assigned as triggers.
  7. # Compatible with 00_SendMessage. (Gosurface or gosector must be assigned or it will begin on startup.)
  8. #
  9. # Flex Variables:
  10. #
  11. # RouteStyle: use 0 for circular (or 2-point) patrol, 1 for linear, and 2 for random
  12. # FramePause: use a constant value, or use 0 for random pauses between 2 and Maxpause (best for pedestrians)
  13. # NumFrames: number of frames in the route, excluding frame 0; NOTE: Inaccurately high framenum results in 1-way patrol
  14. # PatrolSpeed: 1 for walk (default), 2 for run
  15. # MaxPause: longest pause at frame, used only if framepause = 0
  16. #
  17. # [RD] [TL] 
  18. #
  19. # (C) 1999 LucasArts Entertainment Co. All Rights Reserved
  20. # ========================================================================================
  21. symbols
  22.  
  23. message        startup
  24. message        activated
  25. message        entered
  26. message        arrived
  27. message        timer
  28.  
  29. sector        gosector            linkid=1
  30. surface        gosurface            linkid=1
  31.  
  32. thing        patroller
  33.  
  34. float        patrolspeed=1.0
  35. float        framepause=1.0
  36. float        routestyle=0.0
  37. float        numframes=1.0
  38. float        maxpause=10.0
  39.  
  40. flex        beginpatrol            local
  41.  
  42. int            curframe=1            local
  43. int            framenum=0            local
  44. int            direction=1            local    # control forward or backward through frames
  45. int            begun=0                local
  46. int            testnum=0            local
  47.  
  48. end
  49.  
  50. # ========================================================================================
  51. code
  52.  
  53. startup:
  54.  
  55. AISetCutsceneMode(patroller);            # possibly remove this line to let bugs attack while flying
  56.  
  57. if (gosector + gosurface == -2)            # no sector/surface assigned
  58.     {
  59.     call beginpatrol;
  60.     }
  61.  
  62. return;
  63.  
  64. # ........................................................................................
  65. activated:
  66.     
  67. call beginpatrol;
  68.     
  69. return;
  70.  
  71. # ........................................................................................
  72. entered:
  73.     
  74. if (GetSenderID() != 1) return;
  75.     
  76. call beginpatrol;
  77.     
  78. return;
  79.     
  80. # ........................................................................................
  81. beginpatrol:
  82.     
  83. if (begun) return;
  84. begun = 1;
  85.  
  86. AISetMoveSpeed(patroller, patrolspeed);
  87.  
  88. SetTimer(.1);
  89.  
  90. return;
  91.  
  92. # ........................................................................................
  93. arrived:
  94.     
  95. curframe = curframe + direction;
  96. if (curframe > numframes)                    # end of patrol
  97.     {
  98.     if (routestyle == 1)
  99.         {
  100.         direction = -1;                        # if linear, reverse frame directional
  101.         curframe = numframes - 1;
  102.         }
  103.     else
  104.         {
  105.         curframe = 0;                        # if circular, go to frame 0
  106.         }
  107.     }
  108. if ((curframe == -1) && (routestyle == 1))    # if linear and returned to initial frame
  109.     {
  110.     direction = 1;                            # restore forward frame directional
  111.     curframe = 1;
  112.     }
  113. if (routestyle == 2)
  114.     {
  115.     curframe = (Rand() * numframes) + 1;
  116.     }
  117. if (framepause > 0)
  118.     {
  119.     SetTimer(framepause);
  120.     }
  121. else
  122.     {
  123.     SetTimer((Rand() * (maxpause - 1)) + 2);
  124.     }
  125.     
  126. return;
  127.  
  128. # ........................................................................................
  129. timer:
  130.  
  131. AISetLookFrame(patroller, curframe);
  132. AISetMoveFrame(patroller, curframe);
  133.  
  134. return;
  135.  
  136. # ........................................................................................
  137.  
  138. end
  139.